//
//  ShiLiBaoGaoViewController.m
//  MyYiJianKangApp
//
//  Created by 张国文 on 16/5/5.
//  Copyright © 2016年 hangzhouyijiyin. All rights reserved.
//

#import "ShiLiBaoGaoViewController.h"
#import "WaveTableViewCell.h"
#import "BiaoQianOnShiLiBaoGaoTableViewCell.h"
#import "TeBieZhuYiOnShiLiBaoGaoTableViewCell.h"
#import "YouYuChangRenOnShiLiBaoGaoTableViewCell.h"
#import "JianCeResultOnShiLiBaoGaoModel.h"
#import "ChanPinLeiBiaoGeTableViewCell.h"
#import "JianCeDiseaseModel.h"
#import "DanXiangDieaseViewController.h"
#import "ZongHeBaoGaoTableViewCell.h"
#import "ZGWShiLiBaoGaoSimularityPeopleViewController.h"
#import "ZGWJianKangDangAnMessageModel.h"
#import "ZGWLeiOnShiLiBaoGaoModel.h"
#import "ZGWDiseaseOnShiLiBaoGaoModel.h"
#import "ZGWGeXingTianFuOnReportViewController.h"



#define kCurrentUserToken [[NSUserDefaults standardUserDefaults]objectForKey:@"token"]

@interface ShiLiBaoGaoViewController ()<UITableViewDataSource, UITableViewDelegate, ChanPinLeiBiaoGeTableViewCellDelegate>



@property (nonatomic, strong) UITableView *shiLiBaoGaoTableview;

@property (nonatomic, strong) NSMutableArray *diseaseDataArray; // 疾病数据源
@property (nonatomic, strong) NSMutableArray *diseaseNameArray; // 疾病名字数组
@property (nonatomic, strong) NSMutableDictionary *isSelectDic; // 保存是否点击的字典

@property (nonatomic, strong) NSMutableArray *mineBiaoQianArray; // 我的标签数组
@property (nonatomic, strong) NSMutableArray *shouldZhuYiArray; // 需要注意数组
@property (nonatomic, strong) NSMutableArray *youYuChangRenArray; // 由于常人数组

@property (nonatomic, strong) NSTimer *myTimer; // 检查请求是否超时
@property (nonatomic, assign) NSInteger numberOfTime; // 存储请求时间

@property (nonatomic, strong) ZGWJianKangDangAnMessageModel *jianKangDangAnMessageModel; // 健康档案的简略信息

@property (nonatomic, assign) BOOL canClickDisease; // 是否可以点击单项

@end

@implementation ShiLiBaoGaoViewController

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:YES];
    self.tabBarController.tabBar.hidden = YES;
     self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:20]};
     // 每次进入该界面都可以点击单项
     self.canClickDisease = YES;
   // [[NetStatusHandle shareHandle] saveJianKangDangAnShouldRefresh:@"NO"];
    NSLog(@"是否需要刷新%@", [[NetStatusHandle shareHandle] getJianKangDangAnShouldRefresh]);
    // 判断是否需要刷新
    if ([[[NetStatusHandle shareHandle] getJianKangDangAnShouldRefresh] isEqualToString:@"YES"]) {
        // 刷新界面
        [self searchNetAndAddData];
        [[NetStatusHandle shareHandle] saveJianKangDangAnShouldRefresh:@"NO"];
    }
}

- (void)viewWillDisappear:(BOOL)animated
{
    [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
    [self.myTimer invalidate];
    self.numberOfTime = 0;
     self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName:[UIColor whiteColor],NSFontAttributeName:[UIFont boldSystemFontOfSize:22]};
    [super viewWillDisappear:YES];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
    // Do any additional setup after loading the view.
    // navi的修改
    [self changeNavigation];
    // 检查网络并建立数据源
    [self searchNetAndAddData];
    
   
}

// navi的修改
- (void)changeNavigation
{
    self.navigationItem.title = @"示例报告";
    UIImageView *leftImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)];
    leftImageView.image = [UIImage imageNamed:@"houtui"];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftImageView];
    UITapGestureRecognizer *leftTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(lastPage:)];
    [leftImageView addGestureRecognizer:leftTapGes];
    
}

#pragma mark - 返回上一页面
- (void)lastPage:(UITapGestureRecognizer *)tapGes
{
    [self.navigationController popViewControllerAnimated:YES];
}

#pragma mark - 检查网络并建立数据源
- (void)searchNetAndAddData
{
    if ([[[NetStatusHandle shareHandle] getNetStatus] isEqualToString:@"YES"]) {
        // 说明有网络
        // 建立数据源
        [self addData];
        if (self.isShiLiBaoGao == YES) {
            
        } else {
            // 说明不是示例报告
            // 建立计时器，计算是否超时
            self.myTimer = [NSTimer timerWithTimeInterval:1 target:self selector:@selector(goTimeOnJianKangDangAn:) userInfo:nil repeats:YES];
            [[NSRunLoop currentRunLoop] addTimer:self.myTimer forMode:NSRunLoopCommonModes];
            self.numberOfTime = 0;
            // 开始动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
        }
      
        
      
    } else {
        NSLog(@"没有网络");
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kNoNetNoRefresh ToView:self];
    }
}

#pragma mark - 计时器方法
- (void)goTimeOnJianKangDangAn:(NSTimer *)timer
{
    self.numberOfTime++;
    NSLog(@"健康档案时间= %ld", self.numberOfTime);
    if (self.numberOfTime > kZGWQingQiuChaoShi) {
        NSLog(@"健康档案请求超时");
        self.numberOfTime = 0;
        [self.myTimer invalidate];
        // 关闭动画
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
        // 添加提示框
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kQingQiuChaoShiNoReFresh ToView:self];
    }
}

- (void)addData
{
    if (self.isShiLiBaoGao == YES) {
        
        // 建立模拟数据
        [self addMoNiData];
        // 布局
        [self addMySubview];
    } else if (self.isShiLiBaoGaoFormServer == NO) {
        // 健康档案url,说明是健康档案
        NSString *jianKangDangAnUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWGetDetailHealthDangAn, kCurrentUserToken];
       // NSDictionary *paramaterDic = @{@"report_id":@"23"};
        NSDictionary *paramaterDic = @{@"report_id":self.report_id};
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        [manager GET:jianKangDangAnUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
            // 将计时器置为0
            self.numberOfTime = 0;
            [self.myTimer invalidate];
            // 结束动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
            if (!responseObject) {
                return;
            }
            //    NSLog(@"responseObject = %@", responseObject);
            
            
            // 健康档案的简略数据的解析
            NSDictionary *reportDic = [responseObject valueForKey:@"report"];
            // 报告姓名
            self.navigationItem.title = [NSString stringWithFormat:@"%@健康档案", [reportDic valueForKey:@"name"]];
            self.jianKangDangAnMessageModel = [[ZGWJianKangDangAnMessageModel alloc] init];
            [self.jianKangDangAnMessageModel setValuesForKeysWithDictionary:reportDic];
            
            // 类和单项的解析
            NSArray *classificationsArray = [reportDic valueForKey:@"classifications"];
            // 数据源数组
            self.diseaseDataArray = [NSMutableArray array];
            self.diseaseNameArray = [NSMutableArray array];
            self.isSelectDic = [NSMutableDictionary dictionary];
            for (NSDictionary *leiDic in classificationsArray) {
                ZGWLeiOnShiLiBaoGaoModel *leiModel = [[ZGWLeiOnShiLiBaoGaoModel alloc] init];
                [leiModel setValuesForKeysWithDictionary:leiDic];
                
                // 判断时候完全解锁
                NSInteger unlock_number = [[leiDic valueForKey:@"unlock_number"] integerValue];
                NSInteger disease_count = [[leiDic valueForKey:@"disease_count"] integerValue];
                if (unlock_number == 0) {
                    // 未解锁
                    [leiModel setValue:@"3" forKey:@"isWanQuanUnLock"];
                } else if (unlock_number > 0 && unlock_number < disease_count) {
                    // 未完全解锁
                    [leiModel setValue:@"2" forKey:@"isWanQuanUnLock"];
                } else if (unlock_number == disease_count) {
                    // 完全解锁
                    [leiModel setValue:@"1" forKey:@"isWanQuanUnLock"];
                }
                [self.diseaseDataArray addObject:leiModel];
                [self.diseaseNameArray addObject:[leiDic valueForKey:@"classification_name"]];
                [self.isSelectDic setValue:@"NO" forKey:[leiDic valueForKey:@"classification_name"]];
            }
            
            // 优于常人、需要注意、我的标签
            self.youYuChangRenArray = [NSMutableArray array];
            self.shouldZhuYiArray = [NSMutableArray array];
            self.mineBiaoQianArray = [NSMutableArray array];
            NSDictionary *labelsDic = [responseObject valueForKey:@"labels"];
            NSArray *advantageArray = [labelsDic valueForKey:@"advantage"];
            for (NSString *string in advantageArray) {
                [self.youYuChangRenArray addObject:string];
                [self.mineBiaoQianArray addObject:string];
            }
            NSArray *noticeArray = [labelsDic valueForKey:@"notice"];
            for (NSString *string in noticeArray) {
                [self.shouldZhuYiArray addObject:string];
                [self.mineBiaoQianArray addObject:string];
            }
            
            //  NSLog(@"self.diseaseDataArray = %@", self.diseaseDataArray);
            
            // 布局
            [self addMySubview];
        } failure:^(NSURLSessionDataTask *task, NSError *error) {
            // 关闭动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
            // 添加提示框
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kHuoQuDataShiBaiNoRefresh ToView:self];
            // 暂停计时器
            [self.myTimer invalidate];
            self.numberOfTime = 0;
        }];

    } else if (self.isShiLiBaoGaoFormServer == YES) {
        // 说明是从后台获取的示例报告
        NSString *shiLiBaoBaoUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWShiLiBaoGao, kCurrentUserToken];
        AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
        [manager GET:shiLiBaoBaoUrl parameters:nil success:^(NSURLSessionDataTask *task, id responseObject) {
            // 将计时器置为0
            self.numberOfTime = 0;
            [self.myTimer invalidate];
            // 结束动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
            if (!responseObject) {
                return;
            }
            //    NSLog(@"responseObject = %@", responseObject);
            
            
            // 健康档案的简略数据的解析
            NSDictionary *reportDic = [responseObject valueForKey:@"report"];
            // 报告姓名
            self.navigationItem.title = [NSString stringWithFormat:@"%@", [reportDic valueForKey:@"name"]];
            self.jianKangDangAnMessageModel = [[ZGWJianKangDangAnMessageModel alloc] init];
            [self.jianKangDangAnMessageModel setValuesForKeysWithDictionary:reportDic];
            
            // 类和单项的解析
            NSArray *classificationsArray = [reportDic valueForKey:@"classifications"];
            // 数据源数组
            self.diseaseDataArray = [NSMutableArray array];
            self.diseaseNameArray = [NSMutableArray array];
            self.isSelectDic = [NSMutableDictionary dictionary];
            for (NSDictionary *leiDic in classificationsArray) {
                ZGWLeiOnShiLiBaoGaoModel *leiModel = [[ZGWLeiOnShiLiBaoGaoModel alloc] init];
                [leiModel setValuesForKeysWithDictionary:leiDic];
                
                // 判断时候完全解锁
                NSInteger unlock_number = [[leiDic valueForKey:@"unlock_number"] integerValue];
                NSInteger disease_count = [[leiDic valueForKey:@"disease_count"] integerValue];
                if (unlock_number == 0) {
                    // 未解锁
                    [leiModel setValue:@"3" forKey:@"isWanQuanUnLock"];
                } else if (unlock_number > 0 && unlock_number < disease_count) {
                    // 未完全解锁
                    [leiModel setValue:@"2" forKey:@"isWanQuanUnLock"];
                } else if (unlock_number == disease_count) {
                    // 完全解锁
                    [leiModel setValue:@"1" forKey:@"isWanQuanUnLock"];
                }
                [self.diseaseDataArray addObject:leiModel];
                [self.diseaseNameArray addObject:[leiDic valueForKey:@"classification_name"]];
                [self.isSelectDic setValue:@"NO" forKey:[leiDic valueForKey:@"classification_name"]];
            }
            
            // 优于常人、需要注意、我的标签
            self.youYuChangRenArray = [NSMutableArray array];
            self.shouldZhuYiArray = [NSMutableArray array];
            self.mineBiaoQianArray = [NSMutableArray array];
            NSDictionary *labelsDic = [responseObject valueForKey:@"labels"];
            NSArray *advantageArray = [labelsDic valueForKey:@"advantage"];
            for (NSString *string in advantageArray) {
                [self.youYuChangRenArray addObject:string];
                [self.mineBiaoQianArray addObject:string];
            }
            NSArray *noticeArray = [labelsDic valueForKey:@"notice"];
            for (NSString *string in noticeArray) {
                [self.shouldZhuYiArray addObject:string];
                [self.mineBiaoQianArray addObject:string];
            }
            
              NSLog(@"我的标签 = %@", self.mineBiaoQianArray);
            
            // 布局
            [self addMySubview];
        } failure:^(NSURLSessionDataTask *task, NSError *error) {
            // 关闭动画
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
            // 添加提示框
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"通知" Content:kHuoQuDataShiBaiNoRefresh ToView:self];
            // 暂停计时器
            [self.myTimer invalidate];
            self.numberOfTime = 0;

        }];
    }
    
   
    
   
  
}

// 建立模拟数据
- (void)addMoNiData
{
    // 构建健康档案的简略model
    NSDictionary *jianKangDaoAnJianLueDic= [NSDictionary dictionaryWithObjectsAndKeys:@"示例报告", @"name", @"15", @"detect_count", @"0.75", @"health_score", @"0.88", @"health_score_modifed", @"0", @"is_shared", @"0.65", @"proportion", @"0.770", @"proportion_modifed", nil];
    self.jianKangDangAnMessageModel = [[ZGWJianKangDangAnMessageModel alloc] init];
    [self.jianKangDangAnMessageModel setValuesForKeysWithDictionary:jianKangDaoAnJianLueDic];
    // 构建模拟数据源，八大类
    // 心脑血管
    NSMutableArray *xinNaoXueGuanArray = [NSMutableArray arrayWithObjects:@{@"_name":@"冠心病", @"risk_score":@"1.80", @"_is_unlock": @"1", @"risk_level":@"3"},@{@"_name":@"脑卒中", @"_risk_score":@"3.51", @"_is_unlock": @"1", @"risk_level":@"2"}, @{@"_name":@"心肌梗死", @"_risk_score":@"1.03", @"_is_unlock": @"1", @"risk_level":@"2"}, @{@"name":@"高血压", @"risk_score":@"0.85", @"is_unlock": @"1", @"risk_level":@"4"}, @{@"name":@"高血脂症", @"risk_score":@"1.10", @"is_unlock":@"1", @"risk_level":@"1"}, @{@"name":@"房颤", @"risk_score":@"1.63", @"is_unlock":@"1", @"risk_level":@"1"}, @{@"name":@"静脉栓塞", @"risk_score":@"2.52", @"is_unlock": @"1", @"risk_level":@"0"}, nil];
    NSMutableArray *xinNaoXueGuanArray1 = [NSMutableArray array];
    for (int i = 0; i < xinNaoXueGuanArray.count; i++) {
        NSDictionary *tempDic = xinNaoXueGuanArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [xinNaoXueGuanArray1 addObject:diseaseModel];
    }
    // 肿瘤
    NSMutableArray *zhongLiuArray = [NSMutableArray arrayWithObjects:@{@"name":@"肺癌", @"risk_score":@"4.11", @"is_unlock": @"1", @"risk_level":@"1"},@{@"name":@"胃癌", @"risk_score":@"1.44", @"is_unlock": @"1", @"risk_level":@"2"}, @{@"name":@"乳腺癌", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"结直肠癌", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"4"}, nil];
    NSMutableArray *zhongLiuArray1 = [NSMutableArray array];
    for (int i = 0; i < zhongLiuArray.count; i++) {
        NSDictionary *tempDic = zhongLiuArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [zhongLiuArray1 addObject:diseaseModel];
    }
    // 遗传病
    NSMutableArray *yiChuanBingArray = [NSMutableArray arrayWithObjects:@{@"name":@"地中海贫血", @"risk_score":@"1.73", @"is_unlock": @"0", @"risk_level":@"4"},@{@"name":@"镰刀型贫血", @"risk_score":@"3.51", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"遗传性耳聋", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"4"}, @{@"name":@"药物性耳聋", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"苯丙酮尿症", @"risk_score":@"0.45", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"蚕豆症", @"risk_score":@"1.10", @"is_unlock":@"0", @"risk_level":@"2"}, @{@"name":@"渐冻症", @"risk_score":@"1.63", @"is_unlock":@"0", @"risk_level":@"2"}, @{@"name":@"白化病", @"risk_score":@"2.52", @"is_unlock": @"0", @"risk_level":@"1"}, nil];
    NSMutableArray *yiChuanBingArray1 = [NSMutableArray array];
    for (int i = 0; i < yiChuanBingArray.count; i++) {
        NSDictionary *tempDic = yiChuanBingArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [yiChuanBingArray1 addObject:diseaseModel];
    }
    
    // 老年病
    NSMutableArray *laoNianArray = [NSMutableArray arrayWithObjects:@{@"name":@"老年痴呆", @"risk_score":@"1.73", @"is_unlock": @"0", @"risk_level":@"2"},@{@"name":@"帕金森综合征", @"risk_score":@"3.51", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"白内障", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"老年黄褐斑", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"1"}, nil];
    NSMutableArray *laoNianArray1 = [NSMutableArray array];
    for (int i = 0; i < laoNianArray.count; i++) {
        NSDictionary *tempDic = laoNianArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [laoNianArray1 addObject:diseaseModel];
    }
    
    // 自身变异性疾病
    NSMutableArray *ziShenMianYiXingJiBingArray = [NSMutableArray arrayWithObjects:@{@"name":@"类风湿性关节炎", @"risk_score":@"1.73", @"is_unlock": @"0", @"risk_level":@"2"},@{@"name":@"强直性脊柱炎", @"risk_score":@"3.51", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"系统性红斑狼疮", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"4"}, @{@"name":@"哮喘", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"0"}, @{@"name":@"过敏性鼻炎", @"risk_score":@"0.45", @"is_unlock": @"0", @"risk_level":@"1"}, nil];
    
    NSMutableArray *ziShenMianYiXingJiBingArray1 = [NSMutableArray array];
    for (int i = 0; i < ziShenMianYiXingJiBingArray.count; i++) {
        NSDictionary *tempDic = ziShenMianYiXingJiBingArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [ziShenMianYiXingJiBingArray1 addObject:diseaseModel];
    }
    
    // 精神类疾病
    NSMutableArray *jingShenLeiJiBingArray = [NSMutableArray arrayWithObjects:@{@"name":@"抑郁症", @"risk_score":@"1.50", @"is_unlock": @"0", @"risk_level":@"0"},@{@"name":@"精神分裂症", @"risk_score":@"0.8", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"强迫症", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"1"}, nil];
    
    NSMutableArray *jingShenLeiJiBingArray1 = [NSMutableArray array];
    for (int i = 0; i < jingShenLeiJiBingArray.count; i++) {
        NSDictionary *tempDic = jingShenLeiJiBingArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];

        [jingShenLeiJiBingArray1 addObject:diseaseModel];
    }
    
    // 营养代谢
    NSMutableArray *yingYangDaiXieNengLiArray = [NSMutableArray arrayWithObjects:@{@"name":@"解酒基因", @"risk_score":@"1.73", @"is_unlock": @"0", @"risk_level":@"1"},@{@"name":@"吃货基因", @"risk_score":@"3.51", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"烟瘾基因", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"4"}, @{@"name":@"乳糖不耐", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"减肥基因", @"risk_score":@"0.91", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"咖啡因代谢", @"risk_score":@"0.87", @"is_unlock": @"0", @"risk_level":@"1"}, @{@"name":@"叶酸利用能力", @"risk_score":@"0.60", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"维生素D吸收能力", @"risk_score":@"0.75", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"维生素B12吸收能力", @"risk_score":@"0.69", @"is_unlock": @"0", @"risk_level":@"1"},@{@"name":@"钙吸收利用能力", @"risk_score":@"0.73", @"is_unlock": @"0", @"risk_level":@"3"},@{@"name":@"铁吸收利用能力", @"risk_score":@"0.80", @"is_unlock": @"0", @"risk_level":@"0"}, nil];
    
    NSMutableArray *yingYangDaiXieNengLiArray1 = [NSMutableArray array];
    for (int i = 0; i < yingYangDaiXieNengLiArray.count; i++) {
        NSDictionary *tempDic = yingYangDaiXieNengLiArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [yingYangDaiXieNengLiArray1 addObject:diseaseModel];
    }
    // 代谢性疾病
    NSMutableArray *yingYangDaiXieXingJiBingArray = [NSMutableArray arrayWithObjects:@{@"name":@"II型糖尿病", @"risk_score":@"0.87", @"is_unlock": @"0", @"risk_level":@"3"},@{@"name":@"肥胖", @"risk_score":@"2.53", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"痛风", @"risk_score":@"3.11", @"is_unlock": @"0", @"risk_level":@"0"}, nil];
    NSMutableArray *yingYangDaiXieXingJiBingArray1 = [NSMutableArray array];
    for (int i = 0; i < yingYangDaiXieXingJiBingArray.count; i++) {
        NSDictionary *tempDic = yingYangDaiXieXingJiBingArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [yingYangDaiXieXingJiBingArray1 addObject:diseaseModel];
    }
    
    // 个性天赋
    NSMutableArray *geXingTianFuArray = [NSMutableArray arrayWithObjects:@{@"name":@"语言天赋", @"risk_score":@"1.73", @"is_unlock": @"0", @"risk_level":@"1"},@{@"name":@"交际天赋", @"risk_score":@"3.51", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"运动天赋", @"risk_score":@"1.03", @"is_unlock": @"0", @"risk_level":@"2"}, @{@"name":@"音乐天赋", @"risk_score":@"0.85", @"is_unlock": @"0", @"risk_level":@"4"}, @{@"name":@"身高天赋", @"risk_score":@"0.45", @"is_unlock": @"0", @"risk_level":@"1"}, @{@"name":@"近视风险", @"risk_score":@"1.10", @"is_unlock":@"0", @"risk_level":@"0"}, @{@"name":@"肥胖风险", @"risk_score":@"1.63", @"is_unlock":@"0", @"risk_level":@"2"}, @{@"name":@"自闭症", @"risk_score":@"2.52", @"is_unlock": @"0", @"risk_level":@"3"}, @{@"name":@"多动症", @"risk_score":@"1.88", @"is_unlock":@"0", @"risk_level":@"1"}, @{@"name":@"抗空气污染能力", @"risk_score":@"3.2", @"is_unlock": @"0", @"risk_level":@"0"}, nil];
    
    NSMutableArray *geXingTianFuArray1 = [NSMutableArray array];
    for (int i = 0; i < geXingTianFuArray.count; i++) {
        NSDictionary *tempDic = geXingTianFuArray[i];
        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = [[ZGWDiseaseOnShiLiBaoGaoModel alloc] init];
        [diseaseModel setValuesForKeysWithDictionary:tempDic];
        [geXingTianFuArray1 addObject:diseaseModel];
    }
    
    // 1代表完全解锁，2代表未完全解锁，3代表未解锁 DanXiangDataArray
    // 构建模拟数据
    NSArray *moniArray = [NSArray arrayWithObjects:@{@"_classification_name":@"心脑血管疾病", @"_isWanQuanUnLock":@"1", @"_diseaseArray": xinNaoXueGuanArray1},@{@"_classification_name":@"肿瘤", @"_isWanQuanUnLock":@"2", @"_diseaseArray":zhongLiuArray1}, @{@"_classification_name":@"遗传病", @"_isWanQuanUnLock":@"3", @"_diseaseArray":yiChuanBingArray1}, @{@"_classification_name":@"老年病", @"_isWanQuanUnLock":@"3", @"_diseaseArray":laoNianArray1}, @{@"_classification_name":@"自身免疫性疾病", @"_isWanQuanUnLock":@"3", @"_diseaseArray":ziShenMianYiXingJiBingArray1}, @{@"_classification_name":@"精神类疾病", @"_isWanQuanUnLock":@"3", @"_diseaseArray":jingShenLeiJiBingArray1}, @{@"_classification_name":@"营养代谢", @"_isWanQuanUnLock":@"3", @"_diseaseArray":yingYangDaiXieNengLiArray1}, @{@"_classification_name":@"代谢性疾病", @"_isWanQuanUnLock":@"3", @"_diseaseArray":yingYangDaiXieXingJiBingArray1}, @{@"_classification_name":@"个性天赋", @"_isWanQuanUnLock":@"3", @"_diseaseArray":geXingTianFuArray1},nil];
    self.diseaseDataArray = [NSMutableArray array];
    self.diseaseNameArray = [NSMutableArray array];
    self.isSelectDic = [NSMutableDictionary dictionary];
    for (NSDictionary *tempDic in moniArray) {
         ZGWLeiOnShiLiBaoGaoModel *model = [[ZGWLeiOnShiLiBaoGaoModel alloc] init];
        [model setValuesForKeysWithDictionary:tempDic];
        [self.diseaseDataArray addObject:model];
        [self.diseaseNameArray addObject:[tempDic valueForKey:@"_classification_name"]];
    }
    for (NSString *key in self.diseaseNameArray) {
        [self.isSelectDic setValue:@"NO" forKey:key];
    }
}

// 布局
- (void)addMySubview
{
    self.shiLiBaoGaoTableview = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64) style:UITableViewStylePlain];
    self.shiLiBaoGaoTableview.dataSource  = self;
    self.shiLiBaoGaoTableview.delegate = self;
    self.shiLiBaoGaoTableview.bounces = NO;
    self.shiLiBaoGaoTableview.showsVerticalScrollIndicator = NO;
    self.shiLiBaoGaoTableview.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:_shiLiBaoGaoTableview];
    
    // 构建表尾
    UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 30 * kAdjustParamater)];
    footerView.backgroundColor = [UIColor whiteColor];
    self.shiLiBaoGaoTableview.tableFooterView = footerView;
}

#pragma mark - tableView代理
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
         return 4 + self.diseaseDataArray.count;
    }
    // 说明有综合报告
    return 5 + self.diseaseDataArray.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (section <= 3) {
            return 1;
        } else {
            NSString *key = self.diseaseNameArray[section - 4];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            if ([isSelect isEqualToString:@"NO"]) {
                return 0;
            } else if ([isSelect isEqualToString:@"YES"]) {
                return 1;
            }
        }
        return 0;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (section <= 4) {
            return 1;
        } else {
            NSString *key = self.diseaseNameArray[section - 5];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            if ([isSelect isEqualToString:@"NO"]) {
                return 0;
            } else if ([isSelect isEqualToString:@"YES"]) {
                return 1;
            }
        }
        return 0;
    }
    
    return 0;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (indexPath.section == 0) {
            // 示例报告
            static NSString *identifier = @"waveCell";
            WaveTableViewCell *waveCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (waveCell == nil) {
                waveCell = [[WaveTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            waveCell.model = self.jianKangDangAnMessageModel;
            // 纠正前
            UITapGestureRecognizer *jiuZhengQianTapGes1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengQianGes:)];
            [waveCell.shaoBeiOnJiuZhengQianView addGestureRecognizer:jiuZhengQianTapGes1];
            UITapGestureRecognizer *jiuZhengQianTapGes2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengQianGes:)];
            [waveCell.jiuZhengQianDaBaiYongHuLabel addGestureRecognizer:jiuZhengQianTapGes2];
            // 纠正后
            UITapGestureRecognizer *jiuZhengHouTapGes1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengHouGes:)];
            [waveCell.shaoBeiOnJiuZhengHouView addGestureRecognizer:jiuZhengHouTapGes1];
            UITapGestureRecognizer *jiuZhengHouTapGes2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengHouGes:)];
            [waveCell.jiuZhengHouDaBaiYongHuLabel addGestureRecognizer:jiuZhengHouTapGes2];
            waveCell.selectionStyle = UITableViewCellSelectionStyleNone;
            return waveCell;
        } else if (indexPath.section == 1) {
            // 您的标签
            static NSString *identifier = @"woDeBiaoQianCell";
            BiaoQianOnShiLiBaoGaoTableViewCell *biaoQianCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (biaoQianCell == nil) {
                biaoQianCell = [[BiaoQianOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            biaoQianCell.selectionStyle = UITableViewCellSelectionStyleNone;
        //    biaoQianCell.biaoQianArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"钙吸收利用能力弱", @"近视风险高", @"冠心病风险高", @"强直性脊椎炎风险高", @"肥胖风险高", @"携带蚕豆病致病因子",@"脑卒中风险低",@"老年痴呆风险低",@"肺癌风险低",@"痛风风险低",@"抑郁症风险低",@"天生酒量王",@"音乐小王子",@"运动耐力强",@"高血压风险正常",@"白内障风险正常",@"类风湿性关节炎风险正常",@"无强迫症倾向",@"未携带地中海贫血致病因子",@"铁吸收能力一般",@"肌肉软骨组织受伤概率小", nil];
            if (self.isShiLiBaoGao == YES) {
                 biaoQianCell.biaoQianArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"近视风险高", @"肥胖风险高" ,@"脑卒中风险低",@"肺癌风险低",@"痛风风险低",@"抑郁症风险低",@"音乐小王子",@"运动耐力强",@"白内障风险正常",@"无强迫症倾向",@"",@"铁吸收能力一般", nil];
            } else {
                biaoQianCell.biaoQianArray = [NSMutableArray arrayWithArray:self.mineBiaoQianArray];
            }
           
            return biaoQianCell;
        } else if (indexPath.section == 2) {
            // 特别注意
            static NSString *identifier = @"teBieZhuYi";
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (teBieCell == nil) {
                teBieCell = [[TeBieZhuYiOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            teBieCell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (self.isShiLiBaoGao == YES) {
                teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"钙吸收利用能力弱", @"近视风险高", @"冠心病风险高", @"强直性脊椎炎风险高", @"肥胖风险高", @"携带蚕豆病致病因子", nil];
            } else {
                teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithArray:self.shouldZhuYiArray];
            }
            
            return teBieCell;
        } else if (indexPath.section == 3) {
            // 优于常人
            static NSString *identifier = @"youYuChangRen";
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (youYuCell == nil) {
                youYuCell = [[YouYuChangRenOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            youYuCell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (self.isShiLiBaoGao == YES) {
                youYuCell.youYuChangRenArray = [NSMutableArray arrayWithObjects:@"脑卒中风险低", @"老年痴呆风险低", @"肺癌风险低", @"痛风风险低", @"抑郁症风险低", @"天生酒量王", @"音乐小王子", @"运动耐力强", nil];
            } else {
                youYuCell.youYuChangRenArray = [NSMutableArray arrayWithArray:self.youYuChangRenArray];
            }
            
            return youYuCell;
        } else  {
            static NSString *identifier = @"chanPin";
            if (self.diseaseDataArray.count > (indexPath.section - 4)) {
                
                
                // chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
                
//                if (self.isShiLiBaoGao == YES) {
//                    // 获取model
//                    JianCeDiseaseModel *model = self.diseaseDataArray[indexPath.section - 4];
//                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:[model valueForKey:@"DanXiangDataArray"] withIndexPath:indexPath];
//                    chanPinCell.delegate = self;
//                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
//                    return chanPinCell;
//                } else {
//                    ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 4];
//                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:leiModel.diseaseArray withIndexPath:indexPath];
//                    chanPinCell.delegate = self;
//                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
//                    return chanPinCell;
//                }
               
                ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 4];
                if ([leiModel.classification_name isEqualToString:@"心脑血管疾病"]) {
                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:leiModel.diseaseArray withIndexPath:indexPath isDiease:@"YES"];
                    chanPinCell.delegate = self;
                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
                    return chanPinCell;
                } else {
                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:leiModel.diseaseArray withIndexPath:indexPath isDiease:@"NO"];
                    chanPinCell.delegate = self;
                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
                    return chanPinCell;
                }
                
                
            }
        }
        return nil;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (indexPath.section == 0) {
            // 示例报告
            static NSString *identifier = @"waveCell";
            WaveTableViewCell *waveCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (waveCell == nil) {
                waveCell = [[WaveTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            waveCell.selectionStyle = UITableViewCellSelectionStyleNone;
            // 纠正前
            UITapGestureRecognizer *jiuZhengQianTapGes1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengQianGes:)];
            [waveCell.shaoBeiOnJiuZhengQianView addGestureRecognizer:jiuZhengQianTapGes1];
            UITapGestureRecognizer *jiuZhengQianTapGes2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengQianGes:)];
            [waveCell.jiuZhengQianDaBaiYongHuLabel addGestureRecognizer:jiuZhengQianTapGes2];
            // 纠正后
            UITapGestureRecognizer *jiuZhengHouTapGes1 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengHouGes:)];
            [waveCell.shaoBeiOnJiuZhengHouView addGestureRecognizer:jiuZhengHouTapGes1];
            UITapGestureRecognizer *jiuZhengHouTapGes2 = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(jiuZhengHouGes:)];
            [waveCell.jiuZhengHouDaBaiYongHuLabel addGestureRecognizer:jiuZhengHouTapGes2];
            return waveCell;
        } else if (indexPath.section == 1) {
            // 综合报告
            static NSString *identifier = @"zongHeBaoGaoCell";
            ZongHeBaoGaoTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (cell == nil) {
                cell = [[ZongHeBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            return cell;
        } else if (indexPath.section == 2) {
            // 您的标签
            static NSString *identifier = @"woDeBiaoQianCell";
            BiaoQianOnShiLiBaoGaoTableViewCell *biaoQianCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (biaoQianCell == nil) {
                biaoQianCell = [[BiaoQianOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            biaoQianCell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (self.isShiLiBaoGao == YES) {
                biaoQianCell.biaoQianArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"近视风险高", @"肥胖风险高" ,@"脑卒中风险低",@"肺癌风险低",@"痛风风险低",@"抑郁症风险低",@"音乐小王子",@"运动耐力强",@"白内障风险正常",@"无强迫症倾向",@"",@"铁吸收能力一般", nil];
            } else {
                biaoQianCell.biaoQianArray = [NSMutableArray arrayWithArray:self.mineBiaoQianArray];
            }
            return biaoQianCell;
        } else if (indexPath.section == 3) {
            // 特别注意
            static NSString *identifier = @"teBieZhuYi";
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (teBieCell == nil) {
                teBieCell = [[TeBieZhuYiOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            teBieCell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (self.isShiLiBaoGao == YES) {
                teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithObjects:@"吸烟易上瘾", @"叶酸代谢能力差", @"钙吸收利用能力弱", @"近视风险高", @"冠心病风险高", @"强直性脊椎炎风险高", @"肥胖风险高", @"携带蚕豆病致病因子", nil];
            } else {
                teBieCell.teBieZhuYiArray = [NSMutableArray arrayWithArray:self.shouldZhuYiArray];
            }
            return teBieCell;
        } else if (indexPath.section == 4) {
            // 优于常人
            static NSString *identifier = @"youYuChangRen";
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = [tableView dequeueReusableCellWithIdentifier:identifier];
            if (youYuCell == nil) {
                youYuCell = [[YouYuChangRenOnShiLiBaoGaoTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
            }
            youYuCell.selectionStyle = UITableViewCellSelectionStyleNone;
            if (self.isShiLiBaoGao == YES) {
                youYuCell.youYuChangRenArray = [NSMutableArray arrayWithObjects:@"脑卒中风险低", @"老年痴呆风险低", @"肺癌风险低", @"痛风风险低", @"抑郁症风险低", @"天生酒量王", @"音乐小王子", @"运动耐力强", nil];
            } else {
                youYuCell.youYuChangRenArray = [NSMutableArray arrayWithArray:self.youYuChangRenArray];
            }

            return youYuCell;
        } else  {
            static NSString *identifier = @"chanPin";
            
            if (self.diseaseDataArray.count > (indexPath.section - 5)) {
//                if (self.isShiLiBaoGao == YES) {
//                    // 获取model
//                    JianCeDiseaseModel *model = self.diseaseDataArray[indexPath.section - 5];
//                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:[model valueForKey:@"DanXiangDataArray"] withIndexPath:indexPath];
//                    chanPinCell.delegate = self;
//                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
//                    return chanPinCell;
//                } else {
//                    ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 5];
//                    ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:leiModel.diseaseArray withIndexPath:indexPath];
//                    chanPinCell.delegate = self;
//                    //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
//                    return chanPinCell;
//                }
                ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 5];
                ChanPinLeiBiaoGeTableViewCell *chanPinCell = [[ChanPinLeiBiaoGeTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier withDataArray:leiModel.diseaseArray withIndexPath:indexPath isDiease:@"YES"];
                chanPinCell.delegate = self;
                //  chanPinCell.selectionStyle = UITableViewCellSelectionStyleNone;
                return chanPinCell;
            }
            
        }
        return nil;
    }
   // 没有情况
    return nil;
}

#pragma mark - 风险纠正前的手势
- (void)jiuZhengQianGes:(UITapGestureRecognizer *)tapGes
{
    NSLog(@"风险纠正前");
    ZGWShiLiBaoGaoSimularityPeopleViewController *simularityVC = [[ZGWShiLiBaoGaoSimularityPeopleViewController alloc] init];
    simularityVC.isGaiBianQianOrGaiBianHou = @"0";
    [self.navigationController pushViewController:simularityVC animated:YES];
}
#pragma mark - 风险纠正后的手势
- (void)jiuZhengHouGes:(UITapGestureRecognizer *)tapGes
{
    NSLog(@"风险纠正后");
    ZGWShiLiBaoGaoSimularityPeopleViewController *simularityVC = [[ZGWShiLiBaoGaoSimularityPeopleViewController alloc] init];
    simularityVC.isGaiBianQianOrGaiBianHou = @"1";
    [self.navigationController pushViewController:simularityVC animated:YES];
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    if (self.haveZongHeBaoGao == NO) {
        // 没有综合报告
        if (section == 0) {
            // 示例报告
            UIView *shiLiBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            shiLiBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *shiLiBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            shiLiBaoGaoImageV.backgroundColor = kCyanColor;
            shiLiBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            shiLiBaoGaoImageV.layer.masksToBounds = YES;
            [shiLiBaoGaoView addSubview:shiLiBaoGaoImageV];
            
            // 示例报告标题
            UILabel *shiLiBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(shiLiBaoGaoImageV.right + 10 * kAdjustParamater, shiLiBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            if (self.isShiLiBaoGao == YES) {
                shiLiBaoGaoTitleLabel.text = @"这是一份示例报告";
            } else {
                shiLiBaoGaoTitleLabel.text = @"健康档案";
            }
            shiLiBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            shiLiBaoGaoTitleLabel.textColor = [UIColor blackColor];
            shiLiBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [shiLiBaoGaoView addSubview:shiLiBaoGaoTitleLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, shiLiBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [shiLiBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return shiLiBaoGaoView;
        } else if (section == 1) {
            // 您的标签
            UIView *biaoQianView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            biaoQianView.backgroundColor = [UIColor whiteColor];
            UILabel *biaoQianImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            biaoQianImageV.backgroundColor = [UIColor colorWithRed:166 / 255.0 green:208 / 255.0 blue:107 / 255.0 alpha:1];
            biaoQianImageV.layer.cornerRadius = 3 * kAdjustParamater;
            biaoQianImageV.layer.masksToBounds = YES;
            [biaoQianView addSubview:biaoQianImageV];
            
            // 您的标签标题
            UILabel *biaoQianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(biaoQianImageV.right + 10 * kAdjustParamater, biaoQianImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            biaoQianTitleLabel.text = @"您的标签";
            biaoQianTitleLabel.textAlignment = NSTextAlignmentLeft;
            biaoQianTitleLabel.textColor = [UIColor blackColor];
            biaoQianTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [biaoQianView addSubview:biaoQianTitleLabel];
            // 您的标签下方的灰色条
            UILabel *grayLineOnBiaoQianBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoQianImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBiaoQianBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [biaoQianView addSubview:grayLineOnBiaoQianBottom];
            
            return biaoQianView;
            
        } else if (section == 2) {
            // 特别注意
            UIView *teBieZhuYiView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            teBieZhuYiView.backgroundColor = [UIColor whiteColor];
            UILabel *teBieZhuYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            teBieZhuYiImageV.backgroundColor = kYellowColor;
            teBieZhuYiImageV.layer.cornerRadius = 3 * kAdjustParamater;
            teBieZhuYiImageV.layer.masksToBounds = YES;
            [teBieZhuYiView addSubview:teBieZhuYiImageV];
            
            // 特别注意标题
            UILabel *teBieZhuYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(teBieZhuYiImageV.right + 10 * kAdjustParamater, teBieZhuYiImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            teBieZhuYiLabel.text = @"特别注意";
            teBieZhuYiLabel.textAlignment = NSTextAlignmentLeft;
            teBieZhuYiLabel.textColor = [UIColor blackColor];
            teBieZhuYiLabel.font = [UIFont systemFontOfSize:k17Big];
            [teBieZhuYiView addSubview:teBieZhuYiLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnTeBieZhuYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, teBieZhuYiImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnTeBieZhuYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [teBieZhuYiView addSubview:grayLineOnTeBieZhuYiBottom];
            
            return teBieZhuYiView;
        } else if (section == 3) {
            // 优于常人
            UIView *youYuChangRenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            youYuChangRenView.backgroundColor = [UIColor whiteColor];
            UILabel *youYuChangRenImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            youYuChangRenImageV.backgroundColor = [UIColor colorWithRed:138 / 255.0 green:208 / 255.0 blue:212 / 255.0 alpha:1];
            youYuChangRenImageV.layer.cornerRadius = 3 * kAdjustParamater;
            youYuChangRenImageV.layer.masksToBounds = YES;
            [youYuChangRenView addSubview:youYuChangRenImageV];
            
            // 优于常人标题
            UILabel *youYuChangRenLabel = [[UILabel alloc] initWithFrame:CGRectMake(youYuChangRenImageV.right + 10 * kAdjustParamater, youYuChangRenImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            youYuChangRenLabel.text = @"优于常人";
            youYuChangRenLabel.textAlignment = NSTextAlignmentLeft;
            youYuChangRenLabel.textColor = [UIColor blackColor];
            youYuChangRenLabel.font = [UIFont systemFontOfSize:k17Big];
            [youYuChangRenView addSubview:youYuChangRenLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnYouYuChangRenBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, youYuChangRenImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnYouYuChangRenBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [youYuChangRenView addSubview:grayLineOnYouYuChangRenBottom];
            
            return youYuChangRenView;
        } else  {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor whiteColor];
            tempView.tag = 400 + section;
            // 疾病名字
            UILabel *diseaseNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(25 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section - 4];
            diseaseNameLabel.text = tempModel.classification_name;
            diseaseNameLabel.textColor = [UIColor blackColor];
            diseaseNameLabel.font = [UIFont systemFontOfSize:k17Big];
            [tempView addSubview:diseaseNameLabel];
            CGRect newDiseaseNameFrame = diseaseNameLabel.frame;
            newDiseaseNameFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:diseaseNameLabel.text size:17 height:20];
            diseaseNameLabel.frame = newDiseaseNameFrame;
            // 疾病是否已经解锁
            UIImageView *isUnlockImageV = [[UIImageView alloc] initWithFrame:CGRectMake(diseaseNameLabel.right + 10 * kAdjustParamater, diseaseNameLabel.top + 3 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
            NSString *isUnlockString = tempModel.isWanQuanUnLock;
         //   NSLog(@"isUnlockString = %@", isUnlockString);
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiJieSuo-shilibaogao"];
            }
            [tempView addSubview:isUnlockImageV];
            
            // 是否已经解锁的标题
            UILabel *isUnlockLabel = [[UILabel alloc] initWithFrame:CGRectMake(isUnlockImageV.right + 10 * kAdjustParamater, diseaseNameLabel.top, 220 * kAdjustParamater, 20 * kAdjustParamater)];
            //    isUnlockLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            
            isUnlockLabel.textAlignment = NSTextAlignmentLeft;
            [tempView addSubview:isUnlockLabel];
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"已完全解码";
                isUnlockLabel.textColor = kCyanColor;
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未完全解码";
                isUnlockLabel.textColor = kCyanColor;
                //                isUnlockLabel.text = @"立即解码";
                //                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
                //                // 不同的子图大小
                //                NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"立即解码 【本次解码需要10积分】"];
                //                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k15Big] range:NSMakeRange(0, 4)];
                //                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k13Big] range:NSMakeRange(5, 12)];
                //                [isUnlockLabel setAttributedText:str];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未解码";
                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
            }
            // 自适应宽度
            CGRect unlockLabelFrame = isUnlockLabel.frame;
            unlockLabelFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:isUnlockLabel.text size:15 height:20];
            isUnlockLabel.frame = unlockLabelFrame;
            
            UIImageView *jianTouImageV = [[UIImageView alloc] initWithFrame:CGRectMake(340 * kAdjustParamater, 17 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
            NSString *key = self.diseaseNameArray[section - 4];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            
            if ([isSelect isEqualToString:@"YES"]) {
                jianTouImageV.image = [UIImage imageNamed:@"cyanjiantou-createGroup"];
            } else if ([isSelect isEqualToString:@"NO"]) {
                jianTouImageV.image = [UIImage imageNamed:@"huisejiantou-createGroup"];
            }
            [tempView addSubview:jianTouImageV];
            
            UITapGestureRecognizer *selectTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWhat:)];
            [tempView addGestureRecognizer:selectTapGes];
            
            UILabel *grayLineOnBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, 60 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [tempView addSubview:grayLineOnBottom];
            
            return tempView;
        }
        return nil;
    } else if (self.haveZongHeBaoGao == YES) {
        // 有综合报告
        if (section == 0) {
            // 示例报告
            UIView *shiLiBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            shiLiBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *shiLiBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            shiLiBaoGaoImageV.backgroundColor = kCyanColor;
            shiLiBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            shiLiBaoGaoImageV.layer.masksToBounds = YES;
            [shiLiBaoGaoView addSubview:shiLiBaoGaoImageV];
            
            // 示例报告标题
            UILabel *shiLiBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(shiLiBaoGaoImageV.right + 10 * kAdjustParamater, shiLiBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            if (self.isShiLiBaoGao == YES) {
                shiLiBaoGaoTitleLabel.text = @"这是一份示例报告";
            } else {
                shiLiBaoGaoTitleLabel.text = @"健康档案";
            }
            shiLiBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            shiLiBaoGaoTitleLabel.textColor = [UIColor blackColor];
            shiLiBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [shiLiBaoGaoView addSubview:shiLiBaoGaoTitleLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, shiLiBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [shiLiBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return shiLiBaoGaoView;
        } else if (section == 1) {
            // 综合报告
            UIView *zongHeBaoGaoView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            zongHeBaoGaoView.backgroundColor = [UIColor whiteColor];
            UILabel *zongHeBaoGaoImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            zongHeBaoGaoImageV.backgroundColor = [UIColor purpleColor];
            zongHeBaoGaoImageV.layer.cornerRadius = 3 * kAdjustParamater;
            zongHeBaoGaoImageV.layer.masksToBounds = YES;
            [zongHeBaoGaoView addSubview:zongHeBaoGaoImageV];
            
            // 综合报告标题
            UILabel *zongHeBaoGaoTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(zongHeBaoGaoImageV.right + 10 * kAdjustParamater, zongHeBaoGaoImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   shiLiBaoGaoTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            zongHeBaoGaoTitleLabel.text = @"综合报告内容";
            zongHeBaoGaoTitleLabel.textAlignment = NSTextAlignmentLeft;
            zongHeBaoGaoTitleLabel.textColor = [UIColor blackColor];
            zongHeBaoGaoTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [zongHeBaoGaoView addSubview:zongHeBaoGaoTitleLabel];
            // 综合报告下方的灰色条
            UILabel *grayLineOnShiLiBaoBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, zongHeBaoGaoImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnShiLiBaoBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [zongHeBaoGaoView addSubview:grayLineOnShiLiBaoBottom];
            
            return zongHeBaoGaoView;
        } else if (section == 2) {
            // 您的标签
            UIView *biaoQianView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            biaoQianView.backgroundColor = [UIColor whiteColor];
            UILabel *biaoQianImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            biaoQianImageV.backgroundColor = [UIColor colorWithRed:166 / 255.0 green:208 / 255.0 blue:107 / 255.0 alpha:1];
            biaoQianImageV.layer.cornerRadius = 3 * kAdjustParamater;
            biaoQianImageV.layer.masksToBounds = YES;
            [biaoQianView addSubview:biaoQianImageV];
            
            // 您的标签标题
            UILabel *biaoQianTitleLabel = [[UILabel alloc] initWithFrame:CGRectMake(biaoQianImageV.right + 10 * kAdjustParamater, biaoQianImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            biaoQianTitleLabel.text = @"您的标签";
            biaoQianTitleLabel.textAlignment = NSTextAlignmentLeft;
            biaoQianTitleLabel.textColor = [UIColor blackColor];
            biaoQianTitleLabel.font = [UIFont systemFontOfSize:k17Big];
            [biaoQianView addSubview:biaoQianTitleLabel];
            // 您的标签下方的灰色条
            UILabel *grayLineOnBiaoQianBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, biaoQianImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBiaoQianBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [biaoQianView addSubview:grayLineOnBiaoQianBottom];
            
            return biaoQianView;
            
        } else if (section == 3) {
            // 特别注意
            UIView *teBieZhuYiView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            teBieZhuYiView.backgroundColor = [UIColor whiteColor];
            UILabel *teBieZhuYiImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            teBieZhuYiImageV.backgroundColor = kYellowColor;
            teBieZhuYiImageV.layer.cornerRadius = 3 * kAdjustParamater;
            teBieZhuYiImageV.layer.masksToBounds = YES;
            [teBieZhuYiView addSubview:teBieZhuYiImageV];
            
            // 特别注意标题
            UILabel *teBieZhuYiLabel = [[UILabel alloc] initWithFrame:CGRectMake(teBieZhuYiImageV.right + 10 * kAdjustParamater, teBieZhuYiImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            teBieZhuYiLabel.text = @"特别注意";
            teBieZhuYiLabel.textAlignment = NSTextAlignmentLeft;
            teBieZhuYiLabel.textColor = [UIColor blackColor];
            teBieZhuYiLabel.font = [UIFont systemFontOfSize:k17Big];
            [teBieZhuYiView addSubview:teBieZhuYiLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnTeBieZhuYiBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, teBieZhuYiImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnTeBieZhuYiBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [teBieZhuYiView addSubview:grayLineOnTeBieZhuYiBottom];
            
            return teBieZhuYiView;
        } else if (section == 4) {
            // 优于常人
            UIView *youYuChangRenView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61.5 * kAdjustParamater)];
            youYuChangRenView.backgroundColor = [UIColor whiteColor];
            UILabel *youYuChangRenImageV = [[UILabel alloc] initWithFrame:CGRectMake(20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            youYuChangRenImageV.backgroundColor = [UIColor colorWithRed:138 / 255.0 green:208 / 255.0 blue:212 / 255.0 alpha:1];
            youYuChangRenImageV.layer.cornerRadius = 3 * kAdjustParamater;
            youYuChangRenImageV.layer.masksToBounds = YES;
            [youYuChangRenView addSubview:youYuChangRenImageV];
            
            // 优于常人标题
            UILabel *youYuChangRenLabel = [[UILabel alloc] initWithFrame:CGRectMake(youYuChangRenImageV.right + 10 * kAdjustParamater, youYuChangRenImageV.top, 200 * kAdjustParamater, 20 * kAdjustParamater)];
            //   biaoQianTitleLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            youYuChangRenLabel.text = @"优于常人";
            youYuChangRenLabel.textAlignment = NSTextAlignmentLeft;
            youYuChangRenLabel.textColor = [UIColor blackColor];
            youYuChangRenLabel.font = [UIFont systemFontOfSize:k17Big];
            [youYuChangRenView addSubview:youYuChangRenLabel];
            // 示例报告下方的灰色条
            UILabel *grayLineOnYouYuChangRenBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, youYuChangRenImageV.bottom + 20 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnYouYuChangRenBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [youYuChangRenView addSubview:grayLineOnYouYuChangRenBottom];
            
            return youYuChangRenView;
        } else  {
            UIView *tempView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, 61 * kAdjustParamater)];
            tempView.backgroundColor = [UIColor whiteColor];
            tempView.tag = 400 + section;
            // 疾病名字
            UILabel *diseaseNameLabel = [[UILabel alloc] initWithFrame:CGRectMake(25 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater, 20 * kAdjustParamater)];
            ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section - 5];
            diseaseNameLabel.text = tempModel.classification_name;
            diseaseNameLabel.textColor = [UIColor blackColor];
            diseaseNameLabel.font = [UIFont systemFontOfSize:k17Big];
            [tempView addSubview:diseaseNameLabel];
            CGRect newDiseaseNameFrame = diseaseNameLabel.frame;
            newDiseaseNameFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:diseaseNameLabel.text size:17 height:20];
            diseaseNameLabel.frame = newDiseaseNameFrame;
            // 疾病是否已经解锁
            UIImageView *isUnlockImageV = [[UIImageView alloc] initWithFrame:CGRectMake(diseaseNameLabel.right + 10 * kAdjustParamater, diseaseNameLabel.top + 3 * kAdjustParamater, 15 * kAdjustParamater, 15 * kAdjustParamater)];
            NSString *isUnlockString = tempModel.isWanQuanUnLock;
            NSLog(@"isUnlockString = %@", isUnlockString);
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiWanQuanJieSuo-shilibaogao"];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockImageV.image = [UIImage imageNamed:@"newWeiJieSuo-shilibaogao"];
            }
            [tempView addSubview:isUnlockImageV];
            
            // 是否已经解锁的标题
            UILabel *isUnlockLabel = [[UILabel alloc] initWithFrame:CGRectMake(isUnlockImageV.right + 10 * kAdjustParamater, diseaseNameLabel.top, 220 * kAdjustParamater, 20 * kAdjustParamater)];
            //    isUnlockLabel.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.1];
            
            isUnlockLabel.textAlignment = NSTextAlignmentLeft;
            [tempView addSubview:isUnlockLabel];
            if ([isUnlockString isEqualToString:@"1"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"已完全解码";
                isUnlockLabel.textColor = kCyanColor;
            } else if ([isUnlockString isEqualToString:@"2"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未完全解码";
                isUnlockLabel.textColor = kCyanColor;
//                isUnlockLabel.text = @"立即解码";
//                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
//                // 不同的子图大小
//                NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"立即解码 【本次解码需要10积分】"];
//                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k15Big] range:NSMakeRange(0, 4)];
//                [str addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:k13Big] range:NSMakeRange(5, 12)];
//                [isUnlockLabel setAttributedText:str];
            } else if ([isUnlockString isEqualToString:@"3"]) {
                isUnlockLabel.font = [UIFont systemFontOfSize:k15Big];
                isUnlockLabel.text = @"未解码";
                isUnlockLabel.textColor = [[UIColor blackColor] colorWithAlphaComponent:0.7];
            }
            // 自适应宽度
            CGRect unlockLabelFrame = isUnlockLabel.frame;
            unlockLabelFrame.size.width = [[NetStatusHandle shareHandle] adjustWidth:isUnlockLabel.text size:15 height:20];
            isUnlockLabel.frame = unlockLabelFrame;
            
            UIImageView *jianTouImageV = [[UIImageView alloc] initWithFrame:CGRectMake(340 * kAdjustParamater, 17 * kAdjustParamater, 25 * kAdjustParamater, 25 * kAdjustParamater)];
            NSString *key = self.diseaseNameArray[section - 5];
            NSString *isSelect = [self.isSelectDic valueForKey:key];
            
            if ([isSelect isEqualToString:@"YES"]) {
                jianTouImageV.image = [UIImage imageNamed:@"cyanjiantou-createGroup"];
            } else if ([isSelect isEqualToString:@"NO"]) {
                jianTouImageV.image = [UIImage imageNamed:@"huisejiantou-createGroup"];
            }
            [tempView addSubview:jianTouImageV];
            
            UITapGestureRecognizer *selectTapGes = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(selectWhat:)];
            [tempView addGestureRecognizer:selectTapGes];
            
            UILabel *grayLineOnBottom = [[UILabel alloc] initWithFrame:CGRectMake(0, 60 * kAdjustParamater, kScreenWidth, 1 * kAdjustParamater)];
            grayLineOnBottom.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:0.07];
            [tempView addSubview:grayLineOnBottom];
            
            return tempView;
        }
        return nil;
    }
    // 没有这种情况
    return nil;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
        if (indexPath.section == 0) {
            // 动态布局
            WaveTableViewCell *waveCell = (WaveTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return waveCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 1) {
            return 290 * kAdjustParamater;
        } else if (indexPath.section == 2) {
            // 特别注意自适应高度
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = (TeBieZhuYiOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return teBieCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 3) {
            // 优于常人自适应高度
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = (YouYuChangRenOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return youYuCell.grayLineOnBottom.bottom;
        } else {
            // 自适应高度
            ChanPinLeiBiaoGeTableViewCell *tempCell = (ChanPinLeiBiaoGeTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return tempCell.myBiaoGe.bottom + 130 * kAdjustParamater;
        }
        return 0;
    } else if (self.haveZongHeBaoGao == YES) {
        // 说明有综合报告
        if (indexPath.section == 0) {
            // 动态布局
            WaveTableViewCell *waveCell = (WaveTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return waveCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 1) {
            // 真实数据的话需要更改高度，自适应
            return 400 * kAdjustParamater;
        } else if (indexPath.section == 2) {
            return 290 * kAdjustParamater;
        } else if (indexPath.section == 3) {
            // 特别注意自适应高度
            TeBieZhuYiOnShiLiBaoGaoTableViewCell *teBieCell = (TeBieZhuYiOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return teBieCell.grayLineOnBottom.bottom;
        } else if (indexPath.section == 4) {
            // 优于常人自适应高度
            YouYuChangRenOnShiLiBaoGaoTableViewCell *youYuCell = (YouYuChangRenOnShiLiBaoGaoTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return youYuCell.grayLineOnBottom.bottom;
        } else {
            // 自适应高度
            ChanPinLeiBiaoGeTableViewCell *tempCell = (ChanPinLeiBiaoGeTableViewCell *)[self tableView:self.shiLiBaoGaoTableview cellForRowAtIndexPath:indexPath];
            return tempCell.myBiaoGe.bottom + 130 * kAdjustParamater;
        }
        return 0;
    }
   // 没有这种情况
    return 0;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 61 * kAdjustParamater;
}





#pragma mark - 点击选择
- (void)selectWhat:(UITapGestureRecognizer *)tapGes
{
    
    if (self.haveZongHeBaoGao == NO) {
        // 说明没有综合报告
 
        
        // 已经解锁
        NSString *key = self.diseaseNameArray[tapGes.view.tag - 404];
        NSString *isSelect = [self.isSelectDic valueForKey:key];
        if ([isSelect isEqualToString:@"NO"]) {
            [self.isSelectDic setValue:@"YES" forKey:key];
        } else if ([isSelect isEqualToString:@"YES"]) {
            [self.isSelectDic setValue:@"NO" forKey:key];
        }
        [self.shiLiBaoGaoTableview reloadData];

    } else if (self.haveZongHeBaoGao == YES) {
        NSString *key = self.diseaseNameArray[tapGes.view.tag - 405];
        NSString *isSelect = [self.isSelectDic valueForKey:key];
        if ([isSelect isEqualToString:@"NO"]) {
            [self.isSelectDic setValue:@"YES" forKey:key];
        } else if ([isSelect isEqualToString:@"YES"]) {
            [self.isSelectDic setValue:@"NO" forKey:key];
        }
        [self.shiLiBaoGaoTableview reloadData];
//        // 说明有综合报告

    }
    
}

#warning 点击表格的回调
- (void)clickWhatRowCell:(NSInteger)row isUnLock:(NSString *)isUnLock cellIndexPath:(NSIndexPath *)indexPath
{
    if (self.haveZongHeBaoGao == NO) {
        NSLog(@"第%ld个表格,第%ld行,解锁状态:%@", indexPath.section - 4, row, isUnLock);
        if ([isUnLock isEqualToString:@"YES"]) {
            NSLog(@"已经解锁");
            ZGWLeiOnShiLiBaoGaoModel *leiModel1 = self.diseaseDataArray[indexPath.section - 4];
            if ([leiModel1.leiType isEqualToString:@"disease"]) {
                DanXiangDieaseViewController *danXiangDieaseVC = [[DanXiangDieaseViewController alloc] init];
                if (self.diseaseDataArray.count > (indexPath.section - 4)) {
                    ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 4];
                    if (leiModel.diseaseArray.count > row) {
                        danXiangDieaseVC.zgwDiseaseOnShiLiBaoGaoModel = leiModel.diseaseArray[row];
                        danXiangDieaseVC.isShiLiBaoGao = self.isShiLiBaoGao;
                        danXiangDieaseVC.isJianKangDangAn = self.isShiLiBaoGaoFormServer;
                        danXiangDieaseVC.userName = self.userName;
                    }
                }
                [self.navigationController pushViewController:danXiangDieaseVC animated:YES];
            } else {
                ZGWGeXingTianFuOnReportViewController *geXingTianFuOnReportVC = [[ZGWGeXingTianFuOnReportViewController alloc] init];
                if (self.diseaseDataArray.count > (indexPath.section - 4)) {
                    ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 4];
                    if (leiModel.diseaseArray.count > row) {
                        geXingTianFuOnReportVC.zgwTianFuAndDaiXieModel = leiModel.diseaseArray[row];
                        geXingTianFuOnReportVC.userName = self.userName;
                    }
                }
                [self.navigationController pushViewController:geXingTianFuOnReportVC animated:YES];
            }
            
        } else if ([isUnLock isEqualToString:@"NO"]) {
            [self addJieSuoAlertWithCellSection:(indexPath.section - 4)  AndDiseaseRow:row];
        }
    } else if (self.haveZongHeBaoGao == YES) {
        NSLog(@"第%ld个表格,第%ld行,解锁状态:%@", indexPath.section - 5, row, isUnLock);
       
        if ([isUnLock isEqualToString:@"YES"]) {
            NSLog(@"已经解锁");
            DanXiangDieaseViewController *danXiangDieaseVC = [[DanXiangDieaseViewController alloc] init];
            if (self.diseaseDataArray.count > (indexPath.section - 5)) {
                ZGWLeiOnShiLiBaoGaoModel *leiModel = self.diseaseDataArray[indexPath.section - 5];
                if (leiModel.diseaseArray.count > row) {
                    danXiangDieaseVC.zgwDiseaseOnShiLiBaoGaoModel = leiModel.diseaseArray[row];
                    danXiangDieaseVC.isShiLiBaoGao = self.isShiLiBaoGao;
                }
            }
            [self.navigationController pushViewController:danXiangDieaseVC animated:YES];
        } else if ([isUnLock isEqualToString:@"NO"]) {
            [self addJieSuoAlertWithCellSection:(indexPath.section - 5)  AndDiseaseRow:row];
        }
    }
    

   
}

- (void)addJieSuoAlertWithCellSection:(NSInteger)section AndDiseaseRow:(NSInteger)row
{
    if (self.canClickDisease == YES) {
        self.canClickDisease = NO;
        [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
        if (self.isShiLiBaoGaoFormServer == YES) {
            // 说明是示例报告
            // 获取示例报告中对应单项的所需积分
            NSString *shiLiBaoGaoDieaseUnlockCountUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWGetUnlockDiseaseCountAndUserJiFenOfShiLiBaoGao, kCurrentUserToken];
            NSString *reportID = [NSString stringWithFormat:@"%@", self.jianKangDangAnMessageModel.reportID];
            // 获取model
            ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section];
            NSMutableArray *diseaseDanXiangArray = tempModel.diseaseArray;
            ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray[row];
            NSString *diseaseID = diseaseModel.single_disease_id;
            NSDictionary *paramaterDic = @{@"report_id":reportID, @"single_disease_id":diseaseID};
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            [manager GET:shiLiBaoGaoDieaseUnlockCountUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                self.canClickDisease = YES;
                NSString *unlockShouldCountString = [NSString stringWithFormat:@"%@", [responseObject valueForKey:@"unlockCredits"]];
                NSString *userHaveCountString = [responseObject valueForKey:@"current_credits"];
                float unlockShouldCount = [unlockShouldCountString floatValue];
                float userHaveCount = [userHaveCountString floatValue];
                if (userHaveCount >= unlockShouldCount) {
                    [self alertUnLockWithCellSection:section AndDiseaseRow:row withDieaseCount:unlockShouldCount AndUserHaveJiFen:userHaveCount];
                } else {
                    // 说明积分不足
                    [self alertCountNoEnough];
                }
                
            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content:@"单项解锁积分获取失败，请重试" ToView:self];
                self.canClickDisease = YES;
            }];
            
            
        } else if (self.isShiLiBaoGaoFormServer == NO) {
            // 说明是健康档案
            // 获取示例报告中对应单项的所需积分
            NSString *shiLiBaoGaoDieaseUnlockCountUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWGetUnlockDiseaseCountAndUserJiFenOfJianKangReport, kCurrentUserToken];
            NSString *reportID = [NSString stringWithFormat:@"%@", self.jianKangDangAnMessageModel.reportID];
            // 获取model
            ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section];
            NSMutableArray *diseaseDanXiangArray = tempModel.diseaseArray;
            ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray[row];
            NSString *diseaseID = diseaseModel.single_disease_id;
            NSDictionary *paramaterDic = @{@"report_id":reportID, @"single_disease_id":diseaseID};
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            [manager GET:shiLiBaoGaoDieaseUnlockCountUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                self.canClickDisease = YES;
                NSString *unlockShouldCountString = [NSString stringWithFormat:@"%@", [responseObject valueForKey:@"unlockCredits"]];
                NSString *userHaveCountString = [responseObject valueForKey:@"current_credits"];
                float unlockShouldCount = [unlockShouldCountString floatValue];
                float userHaveCount = [userHaveCountString floatValue];
                if (userHaveCount >= unlockShouldCount) {
                    [self alertUnLockWithCellSection:section AndDiseaseRow:row withDieaseCount:unlockShouldCount AndUserHaveJiFen:userHaveCount];
                } else {
                    // 说明积分不足
                    [self alertCountNoEnough];
                }
                
            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content:@"单项解锁积分获取失败，请重试" ToView:self];
                self.canClickDisease = YES;
            }];
        }

    }

}

// 提示积分不足
- (void)alertCountNoEnough
{
    UIAlertController *alertV2 = [UIAlertController alertControllerWithTitle:@"提醒" message:@"您的积分不足不能解锁，您可以查看积分获取规则然后再来解锁" preferredStyle:UIAlertControllerStyleAlert];
    // 修改标题颜色
    NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:@"提醒"];
    [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
    [titleString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
    [alertV2 setValue:titleString forKey:@"attributedTitle"];
    UIAlertAction *sureAction = [UIAlertAction actionWithTitle:@"" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        
    }];
    [alertV2 addAction:sureAction];
    [self presentViewController:alertV2 animated:YES completion:nil];
}

// 提示框解锁
- (void)alertUnLockWithCellSection:(NSInteger)section AndDiseaseRow:(NSInteger)row withDieaseCount:(float)DieaseCount AndUserHaveJiFen:(float)UserHaveJiFen
{
    if (self.isShiLiBaoGaoFormServer == YES) {
        // 说明是示例报告
        // 未解锁
        UIAlertController *alertV = [UIAlertController alertControllerWithTitle:@"提醒" message:[NSString stringWithFormat:@"该单项尚未解锁，解锁需要花费%.0f积分，您目前拥有%.0f积分，您确定要解锁么", DieaseCount, UserHaveJiFen] preferredStyle:UIAlertControllerStyleAlert];
        // 修改标题颜色
        NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:@"提醒"];
        [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
        [titleString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
        [alertV setValue:titleString forKey:@"attributedTitle"];
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"取消");
        }];
        [alertV addAction:cancelAction];
        UIAlertAction *queDingAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"确定解锁");
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
            // 解锁单项url
            NSString *unLockDiseaseUrl = [NSString stringWithFormat:@"%@?token=%@", kZGWUnLockDiseaseOfShiLiBaoGao, kCurrentUserToken];
            NSString *reportID = [NSString stringWithFormat:@"%@", self.jianKangDangAnMessageModel.reportID];
            // 获取model
            ZGWLeiOnShiLiBaoGaoModel *tempModel2 = self.diseaseDataArray[section];
            NSMutableArray *diseaseDanXiangArray2 = tempModel2.diseaseArray;
            ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel2 = diseaseDanXiangArray2[row];
            NSString *diseaseID = diseaseModel2.single_disease_id;
            NSDictionary *paramaterDic = @{@"report_id":reportID, @"single_disease_id":diseaseID};
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            [manager POST:unLockDiseaseUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                NSDictionary *statusDic = [responseObject valueForKey:@"status"];
                NSString *msgString = [statusDic valueForKey:@"msg"];
                if ([msgString isEqualToString:@"unlock success"]) {
                    // 说明解锁成功
                    
                    // 获取model
                    ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section];
                    NSMutableArray *diseaseDanXiangArray = tempModel.diseaseArray;
                    ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray[row];
                    
                    diseaseModel.is_unlock = @"1";
                    
                    // 刷新界面
                    [self.shiLiBaoGaoTableview reloadData];
                    // 判断该类下是否全部开启
                    ZGWLeiOnShiLiBaoGaoModel *tempModel1 = self.diseaseDataArray[section];
                    NSMutableArray *diseaseDanXiangArray1 = tempModel.diseaseArray;
                    int result = 1; // 默认为全部打开
                    int jieMaNumber = 0;
                    for (int i = 0; i < diseaseDanXiangArray1.count; i++) {
                        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray1[i];
                        NSString *isUnLock = diseaseModel.is_unlock;
                        int j = 0;
                        if ([isUnLock isEqualToString:@"1"]) {
                            j = 1;
                            jieMaNumber++;
                        } else if ([isUnLock isEqualToString:@"0"]) {
                            j = 0;
                        }
                        result = result * j;
                    }
                    if (jieMaNumber > diseaseDanXiangArray1.count / 2) {
                        tempModel1.isWanQuanUnLock = @"2";
                        [self.shiLiBaoGaoTableview reloadData];
                    }
                    if (result == 1) {
                        // 说明已经全部解开
                        tempModel1.isWanQuanUnLock = @"1";
                        [self.shiLiBaoGaoTableview reloadData];
                    } else {
                        // 说明没有全部解开
                    }
                }
            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content:@"解锁失败，请重试" ToView:self];
            }];
            
            
        }];
        [alertV addAction:queDingAction];
        [self presentViewController:alertV animated:YES completion:nil];
    } else if (self.isShiLiBaoGaoFormServer == NO) {
        // 说明是健康档案
        // 未解锁
        UIAlertController *alertV = [UIAlertController alertControllerWithTitle:@"提醒" message:[NSString stringWithFormat:@"该单项尚未解锁，解锁需要花费%.0f积分，您目前拥有%.0f积分，您确定要解锁么", DieaseCount, UserHaveJiFen] preferredStyle:UIAlertControllerStyleAlert];
        // 修改标题颜色
        NSMutableAttributedString *titleString = [[NSMutableAttributedString alloc] initWithString:@"提醒"];
        [titleString addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:NSMakeRange(0, 2)];
        [titleString addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:17] range:NSMakeRange(0, 2)];
        [alertV setValue:titleString forKey:@"attributedTitle"];
        UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"取消");
        }];
        [alertV addAction:cancelAction];
        UIAlertAction *queDingAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
            NSLog(@"确定解锁");
            [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] startAnimation];
            // 解锁单项url
            NSString *unLockDiseaseUrl = [NSString stringWithFormat:@"%@?token=%@", KZGWUnlockDiseaseOfJianKangReport, kCurrentUserToken];
            NSString *reportID = [NSString stringWithFormat:@"%@", self.jianKangDangAnMessageModel.reportID];
            // 获取model
            ZGWLeiOnShiLiBaoGaoModel *tempModel2 = self.diseaseDataArray[section];
            NSMutableArray *diseaseDanXiangArray2 = tempModel2.diseaseArray;
            ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel2 = diseaseDanXiangArray2[row];
            NSString *diseaseID = diseaseModel2.single_disease_id;
            NSDictionary *paramaterDic = @{@"report_id":reportID, @"single_disease_id":diseaseID};
            AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
            [manager POST:unLockDiseaseUrl parameters:paramaterDic success:^(NSURLSessionDataTask *task, id responseObject) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                NSDictionary *statusDic = [responseObject valueForKey:@"status"];
                NSString *msgString = [statusDic valueForKey:@"msg"];
                if ([msgString isEqualToString:@"unlock success"]) {
                    // 说明解锁成功
                    
                    // 获取model
                    ZGWLeiOnShiLiBaoGaoModel *tempModel = self.diseaseDataArray[section];
                    NSMutableArray *diseaseDanXiangArray = tempModel.diseaseArray;
                    ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray[row];
                    
                    diseaseModel.is_unlock = @"1";
                    
                    // 刷新界面
                    [self.shiLiBaoGaoTableview reloadData];
                    // 判断该类下是否全部开启
                    ZGWLeiOnShiLiBaoGaoModel *tempModel1 = self.diseaseDataArray[section];
                    NSMutableArray *diseaseDanXiangArray1 = tempModel.diseaseArray;
                    int result = 1; // 默认为全部打开
                    int jieMaNumber = 0;
                    for (int i = 0; i < diseaseDanXiangArray1.count; i++) {
                        ZGWDiseaseOnShiLiBaoGaoModel *diseaseModel = diseaseDanXiangArray1[i];
                        NSString *isUnLock = diseaseModel.is_unlock;
                        int j = 0;
                        if ([isUnLock isEqualToString:@"1"]) {
                            j = 1;
                            jieMaNumber++;
                        } else if ([isUnLock isEqualToString:@"0"]) {
                            j = 0;
                        }
                        result = result * j;
                    }
                    if (jieMaNumber > diseaseDanXiangArray1.count / 2) {
                        tempModel1.isWanQuanUnLock = @"2";
                        [self.shiLiBaoGaoTableview reloadData];
                    }
                    if (result == 1) {
                        // 说明已经全部解开
                        tempModel1.isWanQuanUnLock = @"1";
                        [self.shiLiBaoGaoTableview reloadData];
                    } else {
                        // 说明没有全部解开
                    }
                }
            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] stopAnimation];
                [[JiaZaiAnimationHandle shareJiaZaiAnimationHandle] addAlertTitle:@"提示" Content:@"解锁失败，请重试" ToView:self];
            }];
            
            
        }];
        [alertV addAction:queDingAction];
        [self presentViewController:alertV animated:YES completion:nil];
    }
    
}

#pragma mark - tableViewCell点击
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//    if (self.haveZongHeBaoGao == YES) {
//        // 说明有综合报告
//        if (indexPath.section == 0) {
//
//        }
//    } else if (self.haveZongHeBaoGao == NO) {
//        // 说明没有综合报告
//        if (indexPath.section == 0) {
//            ZGWShiLiBaoGaoSimularityPeopleViewController *simularityVC = [[ZGWShiLiBaoGaoSimularityPeopleViewController alloc] init];
//            [self.navigationController pushViewController:simularityVC animated:YES];
//        }
//    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
